Introduction

The U.S. Census Bureau collects and distributes data under a handful of different programs. Two of the more commonly used programs are the Decennial Census and the American Community Survey (ACS). The Decennial Census is a definitely source of demographic data but only is collected every ten years. The ACS is a program that provides data estimates on a one,three, and five year timeline; ACS data is collected more frequently but the data estimates have a margin of error that must considered. While the Decennial Census only includes basic demographic data such as number of households and total population, the ACS includes many more data points that relate to transportation, income, and housing. Both the Decennial and ACS datasets have similiar data structures. Each row in both datasets include a particular variable and a number the indicates the total number of households or persons that define that variable.

Summary Data

Population and Housing

  nv_acs <- get_acs(geography = "tract", year=2016, 
                variables =  "B01003_001", 
                state = "NV", county=c("Washoe", "Douglas")) %>%
  mutate(data_source="2016 ACS 2016 5-year Estimate")
ca_acs <- get_acs(geography = "tract", year=2016, 
                variables =  "B01003_001", 
                state = "CA",county=c("El Dorado", "Placer")) %>%
  mutate(data_source="2016 ACS 2016 5-year Estimate")
ca_decen <- get_decennial(geography="tract", variables= c("H001001", "P001001"), 
                          state= "CA", year= 2010, county=c("El Dorado", "Placer")) %>% 
  rename(estimate=value) %>% mutate(moe=0, data_source="2010 Decennial Census")
nv_decen <- get_decennial(geography="tract", variables= c("H001001", "P001001"), 
                          state= "NV", year= 2010, county=c("Washoe", "Douglas")) %>% 
  rename(estimate=value) %>% mutate(moe=0, data_source="2010 Decennial Census")
all<- bind_rows(nv_decen,ca_decen, ca_acs, nv_acs) %>%
  left_join(data.frame(tract), by="GEOID") %>%
    filter(!is.na(STATEFP)) %>%
  group_by(variable, data_source) %>% summarise(total=sum(estimate), moe=sum(moe)) %>%
  mutate(variable_name = case_when (variable== "H001001" ~ "Housing Units",
                                    variable== "P001001" ~ "Total Population",
                                    variable== "B01003_001" ~ "Total Population"),
         total=format(total, big.mark=",", scientific=FALSE),
         moe=format(moe, big.mark=",", scientific=FALSE)) %>%
  select(variable_name, variable, total,moe, data_source)
datatable(all, extensions = 'Buttons',
rownames=F,options=list(dom='t', 
          columnDefs = list(list(className = 'dt-center', targets = 0:1))), 
  class = 'cell-border stripe', 
colnames = c('Variable Name', 'Code', 'Total', 'Margin of Error','Data Source'))

Travel Mode to Work

work_transport <- c(Drive= "B08301_002",
                    Walk= "B08301_019",
                    Bike = "B08301_018",
                    `Public Transport` = "B08301_010",
                    `Work from Home` = "B08301_021",
                    Other = "B08301_020",
                    Motorcycle = "B08301_017", 
                    Taxi = "B08301_016")
  nv <- get_acs(geography = "tract", year=2016, 
                variables =  work_transport, 
                state = "NV", geometry = TRUE, summary_var = "B08301_001" )
  ca <- get_acs(geography = "tract", year=2016, 
                variables = work_transport, summary_var = "B08301_001", 
                state = "CA", geometry= TRUE)
   all<- rbind(nv, ca) %>%
    left_join(data.frame(tract), by="GEOID") %>%
    filter(!is.na(STATEFP)) %>%
    dplyr::select(GEOID, NAME.x, variable, estimate, moe, summary_est, summary_moe, County) %>%
    data.frame() %>% select(-geometry.x) %>%
    mutate(source="2016 ACS 2016 5-year Estimate") %>%
    group_by(variable,source ) %>% 
    summarise(number= sum(estimate), total=sum(summary_est), moe=sum(moe)) %>%         
    mutate(total=format(total, big.mark=",", scientific=FALSE),
           number=format(number, big.mark=",", scientific=FALSE),
         moe=format(moe, big.mark=",", scientific=FALSE)) %>%
  select(variable, number, moe,total, source)
  datatable(all, extensions = 'Buttons',
rownames=F,options=list(dom='t', 
          columnDefs = list(list(className = 'dt-center', targets = 0:1))), 
  class = 'cell-border stripe', 
colnames= c ('Variable Name', 'Estimate', 'Margin of Error', 'Total Households','Data Source'))

Household Size

hhsize<- c(`Household Size - 1 Person`="H013002",
           `Household Size - 2 Person`= "H013003",
           `Household Size - 3 Person`="H013004",
            `Household Size - 4 Person`= "H013005",
            `Household Size - 5 Person`= "H013006",
           `Household Size - 6 Person` = "H013007", 
           `Household Size - 7 Person or More` = "H013008")
  nv <- get_decennial(geography = "tract", year=2010, 
                variables =  hhsize, county=c("Washoe", "Douglas"),
                state = "NV", geometry = F, summary_var = "H013001" )
  ca <- get_decennial(geography = "tract", year=2010, county=c("El Dorado", "Placer"),
                variables = hhsize, summary_var = "H013001", 
                state = "CA", geometry= F)
  all<- bind_rows(nv, ca) %>%
    left_join(data.frame(tract), by="GEOID") %>%
    filter(!is.na(STATEFP)) %>%
    dplyr::select(GEOID, NAME.x, variable, value, County, summary_value) %>%
    data.frame() %>%
    mutate(data_source="2010 Decennial Census") %>%
    group_by(variable, data_source) %>% summarise(number=sum(value), total=sum(summary_value)) %>%
   mutate( total=format(total, big.mark=",", scientific=FALSE),
           number=format(number, big.mark=",", scientific=FALSE)) %>%
  select(variable, number, total, data_source)
  
  datatable(all, extensions = 'Buttons',
rownames=F,options=list(dom='t', 
          columnDefs = list(list(className = 'dt-center', targets = 0:1))), 
  class = 'cell-border stripe', colnames = c('Variable Name', 'Count', 'Total','Data Source'))

Demographics: Race

race<- c(`White alone`="P003002",
           `Black or African American alone`= "P003003",
           `American Indian and Alaska Native alone`="P003004",
            `Asian alone`= "P003005",
            `Native Hawaiian and Other Pacific Islander alone`= "P003006",
           `Some Other Race alone` = "P003007", 
           `Two or More Races` = "P003008")
  nv <- get_decennial(geography = "tract", year=2010, 
                variables =  race, county=c("Washoe", "Douglas"),
                state = "NV", geometry = F, summary_var="P003001" )
  ca <- get_decennial(geography = "tract", year=2010, county=c("El Dorado", "Placer"),
                variables = race, summary_var="P003001", 
                state = "CA", geometry= F)
  
all<- bind_rows(nv, ca) %>%
    left_join(data.frame(tract), by="GEOID") %>%
    filter(!is.na(STATEFP)) %>%
    group_by(variable) %>% summarise(value=sum(value), total=sum(summary_value)) %>%
    mutate(source="2010 Decennial Census")

datatable(all, extensions = 'Buttons',
rownames=F,options=list(dom='t', 
          columnDefs = list(list(className = 'dt-center', targets = 0:1))), 
  class = 'cell-border stripe', colnames = c('Variable Name', 'Count', 'Total','Data Source'))

Browse ACS Variables

Search through the list below to determine which variable(s) you want to analyze. You can download all of the variables

acs_var <- load_variables(2016, "acs5", cache = TRUE)

datatable(acs_var, extensions = 'Buttons',
rownames=F,options=list(pageLength = 15, dom = 'Bfrtip',buttons = c('csv','pdf'), 
          columnDefs = list(list(className = 'dt-center', targets = 0:1))), 
  class = 'cell-border stripe')

Browse Decennial Variables

Search through the list below to determine which variable(s) you want to analyze.

decen_var <- load_variables(2010, "sf1", cache = TRUE)

datatable(decen_var, extensions = 'Buttons',
rownames=F,options=list(pageLength = 15, dom = 'Bfrtip',buttons = c('csv','pdf'), 
          columnDefs = list(list(className = 'dt-center', targets = 0:1))), 
  class = 'cell-border stripe')

Tract Map

tmap_mode("view")
tm_shape(tract)+ tm_polygons()

Block Group Map

tmap_mode("view")
tm_shape(block_group)+ tm_polygons()